﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading.Tasks;

namespace WebCalls
{
    class SerializationUtils
    {
        internal static T Deserialize<T>(string result) where T : class
        {
            try
            {
                return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(result);
                //DataContractJsonSerializer sr = new DataContractJsonSerializer(typeof(T));
                //var deserialized = sr.ReadObject(new MemoryStream(StringUtils.StrToByteArray(result)));
                //return (T)deserialized;
            }
            catch (Exception)
            {
                return (T)null;
            }
        }
    }
}
